package retrofit.boot.util;

import org.springframework.util.StringUtils;

import java.net.MalformedURLException;
import java.net.URL;

/**
 * Created by wulg on 2019/11/13
 * description:
 */
public class RetrofitUtils {

    public static String rebuildUrl(String url){
        if (StringUtils.hasText(url) && !(url.startsWith("#{") && url.endsWith("}"))) {
            if (!url.contains("://")) {
                url = "http://" + url;
            }
            try {
                new URL(url);
            }catch (MalformedURLException e) {
                throw new IllegalArgumentException(url + " is malformed", e);
            }
        }
        return url;
    }
}
